package wxshop.web.admin.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import wxshop.api.admin.model.wx.Access_token;
import wxshop.api.admin.model.wx.WxUserInfo;
import wxshop.web.admin.tools.ConstValues;
import wxshop.web.admin.tools.HttpUtil;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by 121874694@qq.com on 2018/3/5.
 */
@RestController
public class CodeController {
	@RequestMapping(value = "/code",method = RequestMethod.GET)
	public void code(HttpServletRequest req, HttpServletResponse resp, @RequestParam("code")String code) throws Exception {
		System.out.println("这是code:"+code);
		String url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="+ ConstValues.APP_ID
				+"&secret="+ConstValues.APP_SECRET
				+"&code="+code
				+"&grant_type=authorization_code";
		String data = HttpUtil.doGet(url,ConstValues.CHARSET);
		System.out.println(data);
	}
}
